//
//  LZRecommendCategoryCell.m
//  LZBS
//
//  Created by 郝庆 on 16/6/8.
//  Copyright © 2016年 haoqing. All rights reserved.
//

#import "LZRecommendCategoryCell.h"
#import "LZRecommendCategory.h"

@interface LZRecommendCategoryCell ()
/** 选中的指示器 */
@property (weak, nonatomic) IBOutlet UIView *selectedIndicator;

@end
@implementation LZRecommendCategoryCell

- (void)layoutSubviews
{
    [super layoutSubviews];
    // 重新调整内部textLabel的frame
    self.textLabel.lz_y = 2;
    self.textLabel.lz_height = self.contentView.lz_height - 2 * self.textLabel.lz_y;
    self.textLabel.textAlignment = NSTextAlignmentCenter;
}

- (void)setCategory:(LZRecommendCategory *)category
{
    _category = category;
    self.textLabel.text = category.name;
}

/**
 * 可以在这个方法中监听cell的选中和取消选中
 */
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    self.selectedIndicator.hidden = !selected;
    
    self.backgroundColor = selected ? [UIColor whiteColor] : LZCommonBgColor;
    self.textLabel.textColor = selected ? self.selectedIndicator.backgroundColor : LZColor(149, 147, 150);
}

@end
